Optimizing ultrashort pulse in fiber laser based on artificial intelligence algorithm

Ultrashort pulses, characterized by their short pulse duration, diverse spectral content, and high peak power, are widely used in fields including laser processing, optical storage, biomedical sciences, and laser imaging. The complex, highly-nonlinear process of ultrashort pulse evolution within fiber lasers is influenced by numerous aspects such as dispersion, loss, gain, and nonlinear effects. Traditionally, the split-step Fourier transforms method is employed for simulating ultrashort pulses in fiber lasers, which involves traversing multiple parameters within the fiber to attain the pulse’s optimal state. The simulation is a significantly time-consuming process. Here, we use a neural network model to fit and predict the impact of multiple parameters on the pulse characteristics within fiber lasers, enabling parameter optimization through genetic algorithms to determine the optimal pulse duration, pulse energy, and peak power. Integrating artificial intelligence algorithms simplifies the acquisition of optimal pulse parameters and enhances our understanding of multiple parameters’ impact on the pulse characteristics. The investigation of ultrashort pulse optimization based on artificial intelligence holds immense potential for laser design.

www.nature.com/scientificreports/fiber lasers 23 .Rapid identification of the laser's optimal operational state, facilitated by these AI algorithms, leads to an efficient optimization process.This method has higher efficiency and accuracy compared to traditional empirical methods, which can significantly improve optimization effectiveness.
In this paper, we employ a neural network (NN) and genetic algorithm (GA) to find the laser cavity's optimal parameter settings in terms of pulse duration, pulse energy, and peak power.The NN is used to fit and predict the impact of multiple parameters on ultrashort pulses in laser cavity, followed by the deployment of a GA to identify optimal pulse duration, energy, and peak power values.The advantage of this method is that it can quickly and effectively comprehensively evaluate the influence of multiple parameters on the ultrashort pulse characteristics, eliminating the need for extensive experiments and complex theoretical analysis.It also offers invaluable insight for the design and optimization of various parameters affecting pulses, which contributes to the formulation of laser schemes.The investigation of ultrashort pulse based on AI paves the way for potential applications in laser precision machining.

Setup of simulated laser cavity
The analysis of pulse formation in fiber lasers based on NNs commences with the preparation of training samples.Here, SSFT is utilized to generate these training samples.Each individual sample encapsulates laser cavity parameters and output pulse information.The configuration of the laser utilized for simulation is depicted in Fig. 1, which is consist of a saturable absorber (SA), a section of passive fiber (PF) and an erbium-doped fiber (EDF) in the laser cavity.The selected laser employs a Gaussian pulse with a central wavelength of 1550 nm as the seed pulse and undertakes the simulation under normal dispersion conditions by modifying different laser cavity parameters.The intensity of input Gaussian pulse is very weak, which can be considered as noise pulse.The pulse within the laser cavity is programmed to repeat 1000 times, with a 5 picosecond (ps) time window set up to record the dynamic behavior of ultrashort pulses.Eventually, a stable pulse is produced.
The transmission of optical pulses within EDF can be expressed through the NLSF, which can be given as 5 : where A represents the slowly changing amplitude of optical pulse; z represents the transmission distance; β 2 represents the group velocity dispersion; γ represents the nonlinear coefficient; Ω represents the gain bandwidth of EDF, g represents the gain coefficient of EDF 24 , where g 0 represents the small signal gain coefficient of EDF, E s represents the saturable energy of EDF.
Here, we employ SSFT for sample simulation, which simulates the propagation process at each step by dividing the entire propagation distance into multiple shorter steps.At each step size, Fourier transform is used for signal conversion from the temporal domain to the frequency domain, addressing linear and non-linear effects, then converting the processed signal back to the temporal domain via an inverse Fourier transform.Through SSFT, an accurate simulation of optical pulse transmission and evolution in nonlinear fiber media is feasible 25 .The length of passive fiber and EDF are both set as 6 m.The output ratio of OC is set as 10%.The SSFT simulation shows that OC has a relatively small impact on the pulse duration and the growth of g 0 will broaden the pulse duration and spectral width.Within the parameter range defined in Table 1, we utilized SSFT to generate a parameter dataset for the laser cavity, encompassing seven key parameters: gain bandwidth of EDF (Ω), gain saturable energy of EDF (E s ), nonlinearity coefficient of EDF (γ EDF ), nonlinearity coefficient of PF (γ PF ), modulation depth of SA (L 0 ), saturable absorber power of SA (P sat ), and small signal gain coefficient of EDF www.nature.com/scientificreports/(g 0 ).Simultaneously, information regarding the stable pulse within the laser cavity, including pulse duration, pulse energy, and peak power, is recorded.The dataset then serves as resources to construct and train NNs for simulating and predicting the pulse dynamics within the laser cavity.During the sample preparation stage, data pertaining to single pulses alone is recorded.On account of the convergence criteria applied being incompatible for fitting multi-pulse situations, the dataset excludes multi-pulse state data.1000 samples were generated via SSFT.Each sample consists of 10 data.These data are seven laser cavity parameters and three output pulse parameters (i.e.pulse duration, pulse energy, and peak power).The seven laser cavity parameters are tunning parameters, and the three output parameters are the dependent variables.These samples were allocated to the training, validation, and testing sets with ratios of 0.7, 0.15, and 0.15, respectively.The training set updates the NN parameters, the validation set counters overfitting, and adjusts the network's hyperparameters, while the test set assesses the trained NN's performance.During the training process, MSE was used to evaluate the mean square error between predicted and actual values.MSE can consider uncertainty when training NNs and effectively prevent overfitting problems.The NN ultimately uses regression graphs to evaluate the fitting effect, where each data point has a corresponding position on the regression graph, where the x coordinate represents the target value (sample result) and the y coordinate represents the output value obtained by the NN.The closer all coefficient points are to the straight-line y = x, the better the fitting effect of the NN.By using NNs for fitting analysis, we can generate function programs related to the nonlinear relationship between the seven laser cavity parameters and pulse information.At the same time, this program can predict the pulse information of the randomly generated seven laser cavity parameters.
To locate the extremum of the mode-locked fiber laser, we adopt a GA along with a fitting function generated by an NN.The GA principle, as shown in Fig. 2, is based on the notion of natural selection, where only the fittest individuals survive the genetic process.In the GA, each individual represents an output pulse state, and their genes consist of seven laser cavity parameter values 26,27 , which means that each individual in GA is equivalent to one sample.Firstly, we randomly create an initial population of individuals within the range given in Table 1.Then, we test these individuals and evaluate their fitness based on the nonlinear functions generated by the NN.Next, select the individual with the highest score from the initial population as the parent of the gene, generate the next generation through crossover and mutation, and form a new population.Then, we compare the new generation of individuals with their parents, and if we find that the new generation of individuals is closer to the  www.nature.com/scientificreports/target than the previous individuals, we stop calculating.In the end, we successfully implement NNs and GAs to search for the extremum of mode-locked fiber lasers, thereby achieving optimal performance.

Simulation results
The sample used for AI algorithm consists of seven laser cavity parameters and three output parameters (i.e.pulse duration, energy, and peak power).The number of samples in sample set is 1000, which and is generated by SSFT method.We initiated with the construction of the first NN with the output layer symbolizing the pulse duration.The mean squared error (MSE) of a NN is defined as the average square of the difference between the predicted value and the actual value.Assuming that the predicted output of the NN is Y and the actual value is T, MSE can be expressed as: Among them, N is the number of samples, Y i is the predicted value of the i th sample, and T i is the actual value of the i th sample.The MSE for this model is calculated as 0.0419 for the training set, 0.0446 for the validation set, 0.1060 for the test set, and 0.0520 for the overall dataset.As can be deciphered from Fig. 3, the regression coefficients for the training set, validation set, test set, and the complete dataset are 99.83%,99.861%, 99.68%, and 99.815% respectively.The correlation between the target value and the predicted value across all dataset exceeds 99%, and the fitting curve in each graph nearly coincides with y = x.This evidence indicates that the NN delivered commendable fitting performance on the training, validation, and testing sets.
The accuracy of the fitting function generated by the NN was put to test by employing 40 sets of randomly generated data.Each parameter value has an equal chance of being selected, and each parameter value is independent from each other.Through the NN, we can obtain 40 sets of output results.Another 40 sets of output results can be obtained by inputting these 40 sets of input parameters into SSFT.We compared the predicted pulse duration by the NN and the pulse duration computed using the SSFT. Figure 4 demonstrates the relative difference in the pulse's duration obtained by two methods, which is calculated using the following formula: where τ NN is the pulse's duration predicted by the NN, τ SSFT is the pulse's duration generated by SSFT.From Fig. 4, it can be observed that the maximum relative error between the two methods is 7%, illustrating that the pulse's duration foreseen by the NN algorithm aligns well with the SSFT method.This evidence indicates that the NN delivered commendable fitting performance on the training, validation, and testing sets.After fitting through NNs, a GA is employed to identify the minimal value of pulse duration.In the case of locating the resonant cavity parameter settings corresponding to the minimum pulse duration, we randomly create a set of resonant cavity parameter within the range given in Table 1, input the NN and obtain the result of pulse duration, we use the seven cavity parameters and output pulse duration as the initial population of individuals.Then, we test these individuals and evaluate their fitness based on the nonlinear functions generated by the NN.Next, select the individual of minimum pulse duration with the highest score from the initial population as the parent of the gene, generate the next generation through crossover and mutation, and form a new population.Then, we compare the new generation of individuals with their parents, and if we find that the new generation of individuals is closer to the minimum pulse duration than the previous individuals, we stop calculating.In the end, we successfully find the minimum pulse duration and its corresponding cavity parameter.Figure 5 shows the performance of GA in progressively discovering the optimal state.It can be observed that as the number of evolutionary generations increases, the optimal value of the fitness function gradually decreases until it stabilizes at a minimum value.This indicates that the GA might have found a solution near the optimal solution in the search space.A comparison between the best fitness function value (Best) and the average fitness function value (Mean) curves serves as an estimation of the performance of GAs and the potency of the evolutionary process.If the Best curve is stable and close to the Mean curve, it indicates that the algorithm can find better solutions in the population and the search process is relatively balanced.Moreover, if the trend of fitness values ceases to improve or stabilizes with an increase in iterations, it might suggest that the algorithm has converged and halted evolving.
The GA successfully succeeded in pinpointing the minimum pulse duration, predicted by the NN, to be 2.03159 ps.This coincided with the following seven laser cavity parameters: Ω = 4.529 × 10 -8 nm, E s = 4.2786 × 10 -11 J, γ EDF = 1 × 10 -3 /(W*m), γ PF = 1 × 10 -3 /(W*m), L 0 = 0.9, P sat = 100 W, g 0 = 1 dB/m.Figure 6 shows the ultrashort pulse's parameter obtained by SSFT.The temporal evolution and spectral evolution of pulse in the laser cavity are depicted in Fig. 6(a), (b) respectively.The steady temporal and spectral pulse profiles within the laser cavity are reflected in Fig. 6(c), (d) respectively.The pulse duration, calculated by the SSFT method with the corresponding seven parameters, is simulated as 2.0269 ps.This implies a negligible relative difference in the pulse duration calculated by both methods and = 2.31%.
For the second phase, the NN was adapted to fit the seven parameters of the laser cavity and pulse energy.Figure 7 displays the MSE derived from comparing the predicted and target values of energy produced by the second NNs.On fitting the NN, the MSE on the training set was found to be 1.5037, on the validation set it was 0.1024, on the test set at 0.0912, and on the entire dataset it scored 1.0816.As per Fig. 7, the regression coefficient of the training set is 99.79%, the validation set is 99.98%, the test set is 99.99%, and the entire dataset at 99.85%, indicating that the NN has excellent fitting of pulse energy.
To evaluate the difference between pulse energy values predicted by the NN and those obtained by using the SSFT method, we used 40 sets of randomly generated data.Figure 9 depicts the relative difference in pulse energy values computed by the two methods across these 40 sets.The calculation formula can be denoted as: where Q NN is the energy predicted by the NN, Q SSFT is the energy generated by SSFT.As demonstrated in Fig. 8, the relative error between the two methods peaks at 4% in the 27th set of data.This comparison suggests that the pulse energy predicted by the NN algorithm aligns reasonably well with the results of the SSFT method.
Figure 9 shows the performance of GA in progressively discovering the optimal state of pulse energy.It can be observed that as the number of evolutionary generations increases, the optimal value of the fitness function    www.nature.com/scientificreports/ The peak power of an ultrashort pulse in a laser can be described as: where P represents the peak power of ultrashort pulses, Q represents the energy of the ultrashort pulse, and τ represents the pulse duration of the ultrashort pulse.The third NN was developed with the output layer representing the peak power of ultrashort pulse.The MSE of this model on the training set scored 0.002, on the validation set 0.024, on the test set 0.0029, and on the entire dataset 0.0054.Figure 10 shows the MSE of comparison between predicted and target values of peak power generated by the third NNs.It is evident that the correlation between the target value and the predicted value across all datasets surpasses 99%, with the fitting curve in each graph nearly coinciding with y = x.This indication suggests the successful fitting of the seven cavity parameters and peak power of the ultrashort pulse.Similar to previous methods, Fig. 11 depicts the relative difference between pulse's peak power as calculated by the two methods across 40 sets of randomly generated data points.The specific calculation formula is as follows: where P NN represents the peak power predicted by the NN, P SSFT represents the peak power generated by SSFT.Reviewing Fig. 11, it is evident that all errors fluctuate between 0 and 7%.Particularly on the seventh set of data, the relative error peaks at 7%.This data corroborates the consistency between the peak power predicted by the NN algorithm and the results of the SSFT method.
Figure 12 shows the performance of GA in increasingly identifying the optimal state of pulse's peak power.As the number of evolutionary generations grows, the optimal value of the fitness function appears to diminish gradually until it stabilizes at a maximum value.GA successfully located the maximum predicted peak power of the pulse to be 21.1061W, and the corresponding seven parameters of laser cavity are as follows: Ω = 2 × 10 -8 nm, E s = 2 × 10 -10 J, γ EDF = 5 × 10 -3 /(W*m), γ PF = 5 × 10 -3 /(W*m), L 0 = 0.9, P sat = 100 W, g 0 = 10 dB/m.The peak power of the pulse, calculated by the SSFT method with these corresponding parameters, is found to be 22.2118 W. The relative difference in the duration of the pulse obtained by two methods is a negligible and = −4.9%.

Discussion
The intelligent algorithm has been designed to locate different pulse extremes-minimum pulse duration, maximum pulse energy, and maximum peak power-of fiber lasers.Through the assistance of AI algorithms for optimization, we have achieved significant improvements.The pulse width has been shortened to a minimum of 2.03159 ps, which is 0.96841 ps smaller than the minimum pulse width range in the dataset.The pulse energy has been increased, with a maximum recorded energy of 115.345 pJ, which exceeds the maximum energy range of 8.345 pJ in the dataset.The peak power has also been improved, with a maximum recorded peak power of ( 6) 21.1061 W, exceeding the maximum power range of 7.1061 W in the dataset.The resonant cavity parameters corresponding to the optimal pulse parameters found through GA are shown in Table 2.
A cross-comparison of the results of seven laser cavity parameters reveals the following patterns: the gain bandwidth of EDF, nonlinear coefficient of EDF, and nonlinear coefficient of PF in the laser cavity parameters linked with minimum pulse duration and maximum pulse energy are strikingly similar-these parameters play a crucial role in the amplification and propagation of optical signals within the laser cavity.Also, the saturable  power of SA and modulating depth of SA for minimum pulse duration and maximum peak power appear identical.The SA is a component that adjusts the amount of light absorption and thus significantly contributes to light intensity control.The small signal gain coefficient of EDF for maximum pulse energy and maximum peak power is also identical, affecting the gain of the pulse within the laser cavity.
During the optimization pulse process, the sample preparation time is approximately 4 h.The time for NN is about 5 s, the time for GA is about 10 s.So, the total time for intelligent algorithms is about 15 s.In GA, mutation rate and crossover rate are two key parameters that significantly affect the results and convergence efficiency of the algorithm.The mutation rate controls the probability of gene mutations, while the crossover rate regulates the probability of gene recombination.By finely adjusting these two parameters, we can optimize the search strategy and convergence speed of the algorithm.Here, we set the mutation rate and crossover rate to 0.4 and 0.5, respectively.Intelligent algorithms can quickly find the desired pulse, which means that once the sample is ready, the intelligent algorithm can quickly optimize and provide an optimize pulse.This kind of speed is very important for real-time applications or systems that require quick response.
It is very important to consider changes of external conditions in the application of intelligent algorithms and laser optimization processes.AI based optimization relies on a set of measured values.The actual values of the measured parameters depend on the ambient conditions of the corresponding laser, and the necessary measurement equipment must stay with the laser over its entire life time.Kobtsev et al. had raised questions about AI based optimization 28 .To ensure the stability of the external environment, a series of standard operating procedures should be set up, including regular calibration and environmental monitoring measures.From the software perspective, If the environmental factors that affect the laser output can be quantified, intelligent algorithms can also be used for environmental optimization, and adaptive algorithms can be written to adjust optimization parameters to ensure that the performance of the laser will not decrease due to environmental changes.In the case of SA, the modulation depth and saturable absorber power can be experimentally measured as a function of the laser's operating time, a corresponding plan for the repeat rate of AI algorithm can be   www.nature.com/scientificreports/formulated.The laser parameters can be adjusted based on the variation pattern of its parameters with the help of AI algorithms, thereby achieving stable output of high-quality laser.Of course, these studies still need to be carried out, and many problems will be encountered during the implementation process, which is one aspect of this work's intended future research.

Methods
Understanding and mastering the relationship between laser parameters and the output characteristics are crucial in laser research and development, as these relationships often determine the performance and application of lasers.Therefore, the NN method employed herein can unravel the complex internal relationships between various parameters by learning from a large number of data samples.NNs, equipped with their multilayer structure and nonlinear activation functions, can capture and model highly nonlinear mapping relationships between input parameters and output characteristics.Once sufficient data samples are procured via the SSFT, we construct the NN illustrated in Fig. 13.The number of samples used here is 1000.This NN comprises an input layer (encasing seven laser parameters), 10 hidden layers, and an output layer corresponding to the laser's three output indicators: pulse duration, pulse energy, and peak power.
The NN is trained using the Levenberg Marquardt (LM) algorithm, The specific steps are as follows:1.Initialize NN parameter, which can be done using a random initialization method; 2. Employ forward propagation to calculate the NN's output for a given input sample and obtain the predicted value; 3. Calculate the loss function using predicted values and actual labels.The Mean Squared Error (MSE) is typically used as the loss function; 4. Calculate the gradient using the backpropagation algorithm.This algorithm calculates the gradient of the loss function on network parameters, or the parameters' partial derivatives; 5. Deploy the LM algorithm to update network parameters.This minimizes the loss function by adjusting the parameters; 6. Check to see if the stop conditions have been met.These conditions could be reaching the maximum iterations or the loss function falling below a certain threshold; 7. Continue training or stop depending on whether the stop condition has been met.
In NNs, the LM algorithm is often employed to adjust the weights and biases of the network to minimize the sum of squared errors between the predicted output and the actual output.The weight increment's calculation formula for the LM algorithm in NNs is as follows [29][30][31][32] where w is referred to as a vector consisting of the weights and thresholds of the neural NN, I is referred to as the identity matrix, μ is referred to as the learning rate, J(w) is referred to as the Jacobian matrix and e(w) is referred to as the error between the expected output value and the actual output value.The LM algorithm is an

Figure 3 .
Figure 3. Comparative analysis of predicted and target values of pulse duration generated by neural networks (NNs).(a) Training dataset regression diagram, (b) validation dataset regression diagram, (c) test dataset regression diagram, (b) regression diagram of all dataset.

Figure 4 .
Figure 4. Relative percentage variation in pulse duration between the NN and SSFT set against the varying number of times.

Figure 5 .
Figure 5. GA iterative graph for finding the minimum pulse duration.

Figure 6 .
Figure 6.SSFT generation of minimum pulse duration.(a) temporal evolution of pulse in laser cavity; (b) spectral evolution of pulse in laser cavity; (c) stable temporal profile of pulse in laser cavity; (d) stable spectral profile of pulse in laser cavity.

Figure 7 .
Figure 7. Comparative analysis of predicted and target values of pulse energy generated by NNs.(a) Training dataset regression diagram, (b) validation dataset regression diagram, (c) test dataset regression diagram, (d) regression diagram of all dataset.

Figure 8 .
Figure 8. Relative percentage variation in pulse energy between the NNs and SSFT varied instances.

Figure 9 .
Figure 9. GA for finding the maximum predicted pulse energy iterative Graph.

Figure 10 .
Figure 10.Comparative analysis of predicted and target values of peak power generated by NNs.(a) Training dataset regression diagram, (b) validation dataset regression diagram, (c) test dataset regression diagram, (d) regression diagram of all dataset.

Figure 11 .
Figure 11.Relative percentage variation in peak power between NNs and SSFT over variable instances.

Figure 12 .
Figure 12.GA searching for maximum peak power iterative graph.

Table 1 .
Range of laser cavity parameters.

Table 2 .
Cavity parameters corresponding to the optimal pulse parameters.